"""API 响应模型定义"""
from fastapi import status
from pydantic import BaseModel


class MessageResponse(BaseModel):
    """消息响应模型 (API Docs)"""
    message: str

response_400 = {
    status.HTTP_400_BAD_REQUEST: {
        "model": MessageResponse,
        "description": "错误的请求"
    }
}

response_401 = {
    status.HTTP_401_UNAUTHORIZED: {
        "model": MessageResponse,
        "description": "未经身份验证的请求"
    }
}


response_403 = {
    status.HTTP_403_FORBIDDEN: {
        "model": MessageResponse,
        "description": "没有权限"
    }
}

response_404 = {
    status.HTTP_404_NOT_FOUND: {
        "model": MessageResponse,
        "description": "无数据"
    }
}

response_409 = {
    status.HTTP_409_CONFLICT: {
        "model": MessageResponse,
        "description": "重复数据"
    }
}

response_422 = {
    status.HTTP_422_UNPROCESSABLE_ENTITY: {
        "description": "输入值错误",
        "content": {
            "application/json": {
                "schema": {
                    "$ref": "#/components/schemas/HTTPValidationError"
                }
            }
        }
    }
}

response_429 = {
    status.HTTP_429_TOO_MANY_REQUESTS: {
        "model": MessageResponse,
        "description": "超出请求限制"
    }
}

response_500 = {
    status.HTTP_500_INTERNAL_SERVER_ERROR: {
        "description": "服务器错误"
    }
}

responses = {
    status.HTTP_403_FORBIDDEN: {"model": MessageResponse},
    status.HTTP_409_CONFLICT: {"model": MessageResponse},
}
